package com.dt76.smallloanbackenduser.controller.ysy;

import com.dt76.smallloanbackenduser.pojo.ysy.ApprovalLoan;
import com.dt76.smallloanbackenduser.remote.ysy.AppRemote;
import com.dt76.smallloanbackenduser.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/ysy")
public class AppController {
    @Autowired
    private AppRemote appRemote;

    @RequestMapping("/account2")
    public String account2(Model model){
        model.addAttribute("appliushuiList",appRemote.qryAppAll2());
        return "pages/ysy/account2";
    }
    @RequestMapping("/delapp/{alId}")
    @ResponseBody
    public Result delapp(@PathVariable String alId){
        return appRemote.delapp(Integer.parseInt(alId));
    }

    @RequestMapping("/addapp")
    public String add(ApprovalLoan approvalLoan){
        //调用新增接口
        Result result = appRemote.addapp(approvalLoan);

        if(result.isSuccess()){
            //刷新全部的信息
//            return "forward:qryConditionPageAll.do?currentPageNo=1";
            return "forward:/ysy/account2?currentPageNo=1";
        }else{
            return "redirect:/ysy/error";
        }

    }
}
